extends StaticBody2D

enum ChangeState{
	VISIBLE,
	UNVISIBLE
}

@export var textrue:Texture2D
@export var current_state:ChangeState

@onready var sprite_2d: Sprite2D = $Sprite2D
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D

func _ready() -> void:
	GameEvents.player_dash.connect(on_player_dash)
	if textrue != null:
		sprite_2d.texture = textrue
	if current_state == ChangeState.UNVISIBLE:
		var tween = create_tween()
		tween.tween_property(self,"modulate:a",.1,.1)
		tween.tween_callback(func():
			collision_shape_2d.set_deferred("disabled", true))

func on_player_dash() -> void:
	if current_state == ChangeState.UNVISIBLE:
		var tween = create_tween()
		tween.tween_property(self,"modulate:a",1,.1)
		tween.tween_callback(func():
			collision_shape_2d.set_deferred("disabled", false))
		current_state = ChangeState.VISIBLE
	else:
		var tween = create_tween()
		tween.tween_property(self,"modulate:a",.1,.1)
		tween.tween_callback(func():
			collision_shape_2d.set_deferred("disabled", true))
		current_state = ChangeState.UNVISIBLE
